package com.roger.match.myapplication;

import com.roger.match.library.MatchButton;
import com.roger.match.library.MatchTextView;
import com.roger.match.library.util.MatchView;
import ohos.agp.components.Component;
import ohos.agp.components.LayoutScatter;
import ohos.agp.window.dialog.*;
import ohos.app.Context;

/**
 * Description:MatchDialog Demo
 * User: Lj
 * Date: 2014-12-04
 * Time: 10:00
 * FIXME
 */

public class MatchDialog extends BaseDialog {

    CommonDialog mDialog;
    MatchTextView matchTextView;
    MatchButton mMatchButton;

    public MatchDialog(Context context) {
        super(context);
    }

    public void init(Context context) {
        Component layout = LayoutScatter.getInstance(context).parse(ResourceTable.Layout_dialog_match, null, false);
        if (mDialog == null) {
            mDialog = new CommonDialog(context);
            mDialog.setContentCustomComponent(layout);
            mDialog.setAutoClosable(true);
            mDialog.setTransparent(true);
            mDialog.show();
            matchTextView = (MatchTextView) layout.findComponentById(ResourceTable.Id_mTextView);
            matchTextView.setTextSize(38f);
            matchTextView.setMatchOutListener(new MatchView.MatchOutListener() {
                @Override
                public void onBegin() {

                }

                @Override
                public void onProgressUpdate(float progress) {

                }

                @Override
                public void onFinish() {
                    mDialog.destroy();
                }
            });

            mMatchButton = (MatchButton) layout.findComponentById(ResourceTable.Id_mButton);
            mMatchButton.setClickedListener(new Component.ClickedListener() {
                @Override
                public void onClick(Component component) {
                    mMatchButton.hide();
                    matchTextView.hide();
                }
            });
        }
    }

}
